<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Server_model extends My_Model
{    
    public function __construct()
    {
        parent::__construct();
        $this->model_name="server list";
        $this->tablename="server";  
    }
        
    public function getpage($page,$key=""){    
        $where=[];
     
        if($key)
        {
            $key=["ipaddr"=>$key];
        }
        return $this->get_items_by_page($where,$page,"backend/server","id desc",[],$key);                
    }



    public function getall(){
        
        $where=[];

        return $this->get_items_by_where($where);                
    }

   
    public function delete($id)
    {
        
        return true;
    }

    public function getitembyid($id){
        $where=array("id"=>$id);
  
        return $this->get_item_by_where($where);
    }


    public function get_name_index()
    {
        $index=[];
        $sites=$this->getall();
        if($sites)
        {   
            foreach($sites as $site)
            {
                $index[$site["id"]]=$site["name"];
            }

        }

        return $index;
    }
    public function create($data){
      
       
        return $this->add_item($data);       
    }

    public function update($id,$data){

        if(is_array($id))
        {
            $where="id in (".implode(",",$id).")";
           
        }else{
            $where=array("id"=>$id);
           
        }
        return $this->update_item($where,$data);

    }

   
}
